package com.ocom.webapi.service.impl;

import com.ocom.common.constant.MapKey;
import com.ocom.common.resp.Result;
import com.ocom.security.utils.SecurityUtils;
import com.ocom.webapi.feign.HumanClientService;
import com.ocom.webapi.service.VisitorApproverService;
import com.ocom.webapi.vo.visitorapprover.AddVo;
import com.ocom.webapi.vo.visitorapprover.ModifyVo;
import com.ocom.webapi.vo.visitorapprover.OnShowVo;
import com.ocom.webapi.vo.visitorapprover.RemoveVo;
import org.apache.catalina.security.SecurityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class VisitorApproverServiceImpl implements VisitorApproverService {

    @Autowired
    private HumanClientService humanClientService;
    /**
     * 审批负责人列表（VisitorApprover/onShow）
     * */
    @Override
    public Result VisitorApproverOnShow(OnShowVo onShowVo) {
        Map<String, Object> map = new HashMap<>();
        MapKey mapKey = new MapKey();
        map.put(mapKey.getKey_comId(), SecurityUtils.getYoCiUser().getComId());
        map.put(mapKey.getKey_status(),onShowVo.getStatus());
        map.put(mapKey.getKey_deptId(),onShowVo.getDeptId());
        map.put(mapKey.getKey_deptName(),onShowVo.getDeptName());
        map.put(mapKey.getKey_pId(),onShowVo.getPId());
        map.put(mapKey.getKey_pName(),onShowVo.getPName());
        map.put(mapKey.getKey_page(),onShowVo.getPage());
        map.put(mapKey.getKey_size(),onShowVo.getSize());
        return humanClientService.GetVisitorApprover(map);
    }

    /**
     * 新增审批负责人（VisitorApprover/add）
     * */
    @Override
    public Result VisitorApproverAdd(AddVo addVo) {
        Map<String, Object> map = new HashMap<>();
        MapKey mapKey = new MapKey();
        map.put(mapKey.getKey_comId(), SecurityUtils.getYoCiUser().getComId());
        map.put(mapKey.getKey_status(),addVo.getStatus());
        map.put(mapKey.getKey_phone(),addVo.getPhone());
        map.put(mapKey.getKey_sendPhone(),addVo.getSendPhone());
        map.put(mapKey.getKey_pId(),addVo.getPId());
        map.put(mapKey.getKey_pName(),addVo.getPName());
        map.put(mapKey.getKey_sendWx(),addVo.getSendWx());
        map.put(mapKey.getKey_deptId(),addVo.getDeptId());
        map.put(mapKey.getKey_deptName(),addVo.getDeptName());
        return humanClientService.AddVisitorApprover(map);
    }

    /**
     * 修改审批负责人（VisitorApprover/modify）
     * */
    @Override
    public Result VisitorApproverModify(ModifyVo modifyVo) {
        Map<String, Object> map = new HashMap<>();
        MapKey mapKey = new MapKey();
        map.put(mapKey.getKey_comId(), SecurityUtils.getYoCiUser().getComId());
        map.put(mapKey.getKey_status(),modifyVo.getStatus());
        map.put(mapKey.getKey_phone(),modifyVo.getPhone());
        map.put(mapKey.getKey_sendPhone(),modifyVo.getSendPhone());
        map.put(mapKey.getKey_pId(),modifyVo.getPId());
        map.put(mapKey.getKey_sendWx(),modifyVo.getSendWx());
        map.put(mapKey.getKey_deptId(),modifyVo.getDeptId());
        map.put(mapKey.getKey_deptName(),modifyVo.getDeptName());
        map.put(mapKey.getKey_id(),modifyVo.getId());
        map.put(mapKey.getKey_pName(),modifyVo.getPName());
        map.put(mapKey.getKey_openid(),modifyVo.getOpenid());
        return humanClientService.UpdateVisitorApprover(map);

    }
    /**
     * 删除审批负责人（VisitorApprover/remove）
     * */
    @Override
    public Result VisitorApproverRemove(RemoveVo removeVo) {
        Map<String, Object> map = new HashMap<>();
        MapKey mapKey = new MapKey();
        map.put(mapKey.getKey_comId(), SecurityUtils.getYoCiUser().getComId());
        map.put(mapKey.getKey_id(),removeVo.getId());
        return humanClientService.DeleteVisitorApprover(map);
    }
}
